import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.JLabel;
import javax.swing.JButton;
public class Game extends JFrame {
    int answer;
    int guess;
    int chances = 7;
    JTextField guessArea;
    JLabel title;
    JLabel prompt;
    JLabel hint;
    JButton guessBtn;
    JButton againBtn;
    JButton gameover;

    Game(){
        initGUI();
        start();
    }

    void initGUI() {
        setTitle("JAVA猜数字");
        setSize(450, 300);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setLayout(null);

        title = new JLabel("JAVA猜数字");
        title.setBounds(175, 10, 100, 30);
        add(title);
        prompt = new JLabel("请输入一个1-100之间的数字：");
        prompt.setBounds(80, 50, 180, 30);
        add(prompt);

        guessArea = new JTextField();
        guessArea.setBounds(260, 50, 50, 30);
        add(guessArea);


        guessBtn = new JButton("猜一下");
        guessBtn.setBounds(170, 90, 80, 20);
        add(guessBtn);

        againBtn = new JButton("再玩一次");
        againBtn.setBounds(170, 90, 80, 20);
        add(againBtn);

        hint = new JLabel("请点击猜一下按钮完成一次猜测");
        hint.setBounds(10,180,400,30);
        add(hint);

        setVisible(true);
    }
    void gameOver(){
        gameover = new JButton("再玩一次");
        gameover.setBounds(170,90,80,20);
    }
    void start(){
        answer = (int)(Math.random()+100+1);
        chances = 7;
        guessBtn.setEnabled(true);
        guessArea.setEnabled(true);
        againBtn.setVisible(false);
        hint.setText("欢迎来到猜数字，点击猜一下开始游戏！");
    }

    void GuessActionListener(){

    }
    public static void main(String args []){
        Game game = new Game();
    }
}